package com.lagou.bigdata.task01;

import java.io.Serializable;

public class Student implements Serializable {
    private static final long serialVersionUID = 9209829552503184547L;
    private int id;
    private String name;
    private int age;

    public Student() {
    }

    public Student(int id, String name, int age) throws StudentIdException, AgeException {
        setId(id);
        setName(name);
        setAge(age);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) throws StudentIdException {
        if (id <100 || id >10000) {
            throw new StudentIdException("学号设置不合理！");
        } else {
            this.id = id;
        }

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws AgeException {
        if (age <7 || age > 130) {
            throw new AgeException("年龄设置不合理！");
        } else {
            this.age = age;
        }

    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
